﻿using BasicData.Application.Input;
using BasicData.Application.Input.LineModel;
using BasicData.Application.Output;
using BasicData.Application.Services.Line;
using BasicData.Result;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BasicData.Api.Controllers
{
    /// <summary>
    /// 产线管理
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    
   
    public class LineController : ControllerBase
    {
        ILineServices services;
        ILogger<LineController> logger;
        public LineController(ILineServices services, ILogger<LineController> logger)
        {
            this.services = services;
            this.logger = logger;
        }
        /// <summary>
        /// 添加产线
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddLine(LineInput input)
        {
            logger.LogInformation("添加产线");
            return services.AddLine(input);
        }
        /// <summary>
        /// 删除产线
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> DeleteLine(long id)
        {
            logger.LogInformation("删除产线");
            return services.DeleteLine(id);
        }
        /// <summary>
        /// 获取产线
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<LineOutput> GetLine([FromQuery]PageInput input)
        {
            logger.LogInformation("获取产线");
            return services.GetLine(input);
        }
        /// <summary>
        /// 修改产线
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPut]
        public ApiResult<int> UpdateLine(UpdateLineInput input)
        {
            logger.LogInformation("修改产线");
            return services.UpdateLine(input);
        }
    }
}
